﻿using System;
using NPMonitor.Implementation.Store;
using NPMonitor.Interfaces;

namespace NPMonitor.Web
{
    public partial class _Default : BasePage
    {
        public override string FunctionName
        {
            get { return FunctionEnum.Machines.ToString(); }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DoDataBind();
            }
        }

        public void BindMachineList()
        {
            ucMachineList.BindData(-1);
        }
        public void DoDataBind()
        {
            IMachineStore ims = new MachineStore();
            var machinePoolList = ims.GetAllMachinePool();
            this.rpMachinePool.DataSource = machinePoolList;
            this.rpMachinePool.DataBind();
        }

        public string PoolId
        {
            get
            {
                var result = Request.Params["poolId"];
                if (result == null)
                    return "";
                else
                    return result.ToString();
            }
        }

        public string GetSelectItemClass(string poolId)
        {
            if (string.Compare(PoolId, poolId, true) == 0)
                return "class='on'";
            else
                return "";
        }

        public void ShowSuccessfulDiv()
        {
            ucMachineList.ShowSuccessfulDiv();
        }

    }
}
